package org.mm.model;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;



/**
 * The persistent class for the therapy_tasks database table.
 *
 */
@Entity
@Table(name="therapy_tasks")
public class TherapyTask implements Serializable {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 3039794261779440313L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="therapy_task_id")
	private Long therapyTaskId;

	@Column(name="therapy_task_creation_date")
	private Timestamp therapyTaskCreationDate;

	@Column(name="therapy_task_cron_expression")
	private String therapyTaskCronExpression;

	@Column(name="therapy_task_description")
	private String therapyTaskDescription;

	@Column(name="therapy_task_end_date")
	private Timestamp therapyTaskEndDate;

	@Column(name="therapy_task_last_modification_date")
	private Timestamp therapyTaskLastModificationDate;

	@Column(name="therapy_task_short_description")
	private String therapyTaskShortDescription;

	@Column(name="therapy_task_start_date")
	private Timestamp therapyTaskStartDate;

	@Version
	@Column(name="therapy_task_version")
	private int therapyTaskVersion;

	//bi-directional many-to-one association to TherapyTaskEvent
	@OneToMany(mappedBy="therapyTask", fetch=FetchType.LAZY)
	private List<TherapyTaskEvent> therapyTaskEvents;

	//bi-directional many-to-one association to Drug
	@ManyToOne
	@JoinColumn(name="therapy_task_drug_id")
	private Drug drug;

	//bi-directional many-to-one association to Sensor
	@ManyToOne
	@JoinColumn(name="therapy_task_sensor_id")
	private Sensor sensor;

	//bi-directional many-to-one association to Therapy
	@ManyToOne
	@JoinColumn(name="therapy_task_therapy_id")
	private Therapy therapy;

	//bi-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name="therapy_task_created_by_user")
	private User user1;

	//bi-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name="therapy_task_last_modified_by_user")
	private User user2;

	public TherapyTask() {
	}

	public TherapyTask(Long therapyTaskId) {
		this.therapyTaskId = therapyTaskId;
	}

	public Long getTherapyTaskId() {
		return this.therapyTaskId;
	}

	public void setTherapyTaskId(Long therapyTaskId) {
		this.therapyTaskId = therapyTaskId;
	}

	public Timestamp getTherapyTaskCreationDate() {
		return this.therapyTaskCreationDate;
	}

	public void setTherapyTaskCreationDate(Timestamp therapyTaskCreationDate) {
		this.therapyTaskCreationDate = therapyTaskCreationDate;
	}

	public String getTherapyTaskCronExpression() {
		return this.therapyTaskCronExpression;
	}

	public void setTherapyTaskCronExpression(String therapyTaskCronExpression) {
		this.therapyTaskCronExpression = therapyTaskCronExpression;
	}

	public String getTherapyTaskDescription() {
		return this.therapyTaskDescription;
	}

	public void setTherapyTaskDescription(String therapyTaskDescription) {
		this.therapyTaskDescription = therapyTaskDescription;
	}

	public Timestamp getTherapyTaskEndDate() {
		return this.therapyTaskEndDate;
	}

	public void setTherapyTaskEndDate(Timestamp therapyTaskEndDate) {
		this.therapyTaskEndDate = therapyTaskEndDate;
	}

	public Timestamp getTherapyTaskLastModificationDate() {
		return this.therapyTaskLastModificationDate;
	}

	public void setTherapyTaskLastModificationDate(Timestamp therapyTaskLastModificationDate) {
		this.therapyTaskLastModificationDate = therapyTaskLastModificationDate;
	}

	public String getTherapyTaskShortDescription() {
		return this.therapyTaskShortDescription;
	}

	public void setTherapyTaskShortDescription(String therapyTaskShortDescription) {
		this.therapyTaskShortDescription = therapyTaskShortDescription;
	}

	public Timestamp getTherapyTaskStartDate() {
		return this.therapyTaskStartDate;
	}

	public void setTherapyTaskStartDate(Timestamp therapyTaskStartDate) {
		this.therapyTaskStartDate = therapyTaskStartDate;
	}

	public int getTherapyTaskVersion() {
		return this.therapyTaskVersion;
	}

	public void setTherapyTaskVersion(int therapyTaskVersion) {
		this.therapyTaskVersion = therapyTaskVersion;
	}

	public List<TherapyTaskEvent> getTherapyTaskEvents() {
		return this.therapyTaskEvents;
	}

	public void setTherapyTaskEvents(List<TherapyTaskEvent> therapyTaskEvents) {
		this.therapyTaskEvents = therapyTaskEvents;
	}

	public TherapyTaskEvent addTherapyTaskEvent(TherapyTaskEvent therapyTaskEvent) {
		getTherapyTaskEvents().add(therapyTaskEvent);
		therapyTaskEvent.setTherapyTask(this);

		return therapyTaskEvent;
	}

	public TherapyTaskEvent removeTherapyTaskEvent(TherapyTaskEvent therapyTaskEvent) {
		getTherapyTaskEvents().remove(therapyTaskEvent);
		therapyTaskEvent.setTherapyTask(null);

		return therapyTaskEvent;
	}

	public Drug getDrug() {
		return this.drug;
	}

	public void setDrug(Drug drug) {
		this.drug = drug;
	}

	public Sensor getSensor() {
		return this.sensor;
	}

	public void setSensor(Sensor sensor) {
		this.sensor = sensor;
	}

	public Therapy getTherapy() {
		return this.therapy;
	}

	public void setTherapy(Therapy therapy) {
		this.therapy = therapy;
	}

	public User getUser1() {
		return this.user1;
	}

	public void setUser1(User user1) {
		this.user1 = user1;
	}

	public User getUser2() {
		return this.user2;
	}

	public void setUser2(User user2) {
		this.user2 = user2;
	}

	public String toString() {
		StringBuilder b = new StringBuilder();
		b.append("therapyTaskId=").append(therapyTaskId).append(" - ");
		if (therapyTaskEvents != null) {
			b.append("therapyTaskEvents\n");
			for (TherapyTaskEvent therapyTaskEvent : therapyTaskEvents) {
				b.append(therapyTaskEvent.toString());
			}
		}
		b.append("\n");
		return b.toString();
	}

}